import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { SceneRange } from "../../scene/map/SceneRange";
import { Global } from "../../../../com/gengine/global/Global";
import { TweenMax } from "../../../../com/greensock/TweenMax";
import { Quint } from "../../../../com/greensock/easing/Quint";
import { TaskCache } from "../../cache/TaskCache";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { MagicTowerInfoTitle } from "./magicTower/MagicTowerInfoTitle";
import { TowerInfoHideButton } from "./magicTower/TowerInfoHideButton";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class CopyInfoPanelBase
    
    export  class CopyInfoPanelBase extends View
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super();
            this._moveRec = new Object /* flash.geom.Rectangle */();
            this.mouseEnabled = false;
            this.layer = LayerManager.uiLayer;
            this._zoomPic = arg1;
            this.createChildren();
            this.autoUpdatePosition = true;
            return;
        }

        /* internal  */onMoveBtnMouseDown(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._moveRec.x = 0;
            this._moveRec.y = 0;
            this._moveRec.width = SceneRange.display.width - 30;
            this._moveRec.height = SceneRange.display.height - 30;
            startDrag(false, this._moveRec);
            Global.stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onStageMouseUpHandler);
            return;
        }

        /* internal  */onStageMouseUpHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            stopDrag();
            Global.stage.removeEventListener(flash.events.MouseEvent.MOUSE_UP, this.onStageMouseUpHandler);
            return;
        }

        public updatePosition(): void
        {
            if (this._zoomBtn.show) 
            {
                x = Global.stage.stageWidth - 284;
                y = 180 + 20 * Global.stage.stageHeight / 1000;
            }
            else 
            {
                x = Global.stage.stageWidth - 260;
                y = 288;
            }
            return;
        }

        public updateStatus(arg1: string): void
        {
            if (arg1 != CopyInfoPanelBase.Expand) 
            {
                if (arg1 == CopyInfoPanelBase.Shrink) 
                {
                    this._zoomBtn.show = false;
                    if (this._moveSp.parent) 
                    {
                        removeChild(this._moveSp);
                    }
                }
            }
            else 
            {
                this._zoomBtn.show = true;
                if (!this._moveSp.parent) 
                {
                    addChild(this._moveSp);
                }
            }
            return;
        }

        public hidePanel(): void
        {
            if (this._showTween && this._showTween.active) 
            {
                this._showTween.kill();
            }
            x = SceneRange.display.width - 260;
            y = 288;
            this._hideTween = TweenMax.to(this._moveSp, 0.2, {"x": 260, "ease": Quint.easeOut, "onComplete": this.onHideEnd});
            this._zoomBtn.show = false;
            return;
        }

        /* internal  */onHideEnd(): void
        {
            if (this._moveSp.parent) 
            {
                removeChild(this._moveSp);
            }
            return;
        }

        protected setPosition(): void
        {
            x = SceneRange.display.width - 284;
            y = 180 + 20 * SceneRange.display.height / 1000;
            return;
        }

        public showPanel(): void
        {
            if (TaskCache.showTrack) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, false));
            }
            if (this._hideTween && this._hideTween.active) 
            {
                this._hideTween.kill();
            }
            this.setPosition();
            this._showTween = TweenMax.to(this._moveSp, 0.2, {"x": 0, "ease": Quint.easeIn});
            this._zoomBtn.show = true;
            if (!this._moveSp.parent) 
            {
                addChild(this._moveSp);
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            Dispatcher.addEventListener(EventName.TrackClick, this.onTaskTrackClick);
            return;
        }

        /* internal  */onTaskTrackClick(arg1: DataEvent): void
        {
            if (arg1.data && this._zoomBtn.show) 
            {
                this.hidePanel();
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            Dispatcher.removeEventListener(EventName.TrackClick, this.onTaskTrackClick);
            return;
        }

        
        {
            CopyInfoPanelBase.Expand = "伸展";
            CopyInfoPanelBase.Shrink = "收缩";
        }

        protected createChildren(): void
        {
            this._moveSp = new Object /* flash.display.Sprite */();
            this._moveSp.mouseEnabled = false;
            this.addChild(this._moveSp);
            this._moveBtn = ObjCreate.createGButton("", 0, 0, 24, 22, this._moveSp, "MoveBtn");
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveBtnMouseDown);
            this._moveBtn.toolTipData = HTMLUtil.addColor(Language.getString(60068), "#FFFFFF");
            this._titleSp = new MagicTowerInfoTitle();
            this._titleSp.x = 24;
            this._titleSp.y = -4;
            this._titleSp.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveBtnMouseDown);
            this._moveSp.addChild(this._titleSp);
            this._zoomBtn = new TowerInfoHideButton(this._zoomPic);
            this._zoomBtn.x = 248;
            this._zoomBtn.y = 11;
            this.addChild(this._zoomBtn);
            this._zoomBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onZoomBtnClick);
            this._bg = new Object /* flash.display.Bitmap */(new Object /* flash.display.BitmapData */(260, 200, false, 0));
            this._bg.y = 22;
            this._bg.alpha = 0.45;
            this._moveSp.addChild(this._bg);
            this._bodySp = new Object /* flash.display.Sprite */();
            this._bodySp.y = 22;
            this._bodySp.mouseEnabled = false;
            this._moveSp.addChild(this._bodySp);
            return;
        }

        public set autoUpdatePosition(arg1: Boolean)
        {
            this._autoUpdatePosition = arg1;
            if (this._autoUpdatePosition) 
            {
                Global.stage.addEventListener(flash.events.Event.RESIZE, this.onStageResizeHandler);
                this.updatePosition();
            }
            else 
            {
                Global.stage.removeEventListener(flash.events.Event.RESIZE, this.onStageResizeHandler);
            }
            return;
        }

        public set title(arg1: string)
        {
            this._titleSp.title = arg1;
            return;
        }

        public updateInfos(arg1): void
        {
            return;
        }

        protected onStageResizeHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._autoUpdatePosition) 
            {
                this.updatePosition();
            }
            return;
        }

        protected onZoomBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._zoomBtn.show) 
            {
                this.hidePanel();
            }
            else 
            {
                this.showPanel();
            }
            return;
        }

        /* internal */ /* var */_moveRec: Object /* flash.geom.Rectangle */;

        /* internal */ /* var */_hideTween: TweenMax;

        /* internal */ /* var */_showTween: TweenMax;

        protected /* var */_moveSp: Object /* flash.display.Sprite */;

        protected /* var */_bg: Object /* flash.display.Bitmap */;

        protected /* var */_bodySp: Object /* flash.display.Sprite */;

        protected /* var */_left: int=10;

        protected /* var */_moveBtn: GButton;

        protected /* var */_titleSp: MagicTowerInfoTitle;

        protected /* var */_zoomBtn: TowerInfoHideButton;

        /* internal */ /* var */_zoomPic: string;

        /* internal */ /* var */_autoUpdatePosition: Boolean;

        public static /* var */Shrink: string="收缩";

        public static /* var */Expand: string="伸展";
    }
